using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
using mscorsvw;

namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RSACryptoServiceProvider rsaCryptoServiceProvider = new RSACryptoServiceProvider(2048);
            File.WriteAllText("Public.xml", rsaCryptoServiceProvider.ToXmlString(false));
            File.WriteAllText("All.xml", rsaCryptoServiceProvider.ToXmlString(true));
        }

        private void Test_Click(object sender, EventArgs e)
        {
            CLRService clrService = new CLRService();
            CLRService.SendMail();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            GZipStream gZipStream = new GZipStream(new FileStream("al.zip", FileMode.CreateNew), CompressionMode.Compress);
            byte[] data = File.ReadAllBytes("All.xml");
            gZipStream.Write(data, 0, data.Length);
            gZipStream.Flush();
            gZipStream.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            RSACryptoServiceProvider rsaCryptoServiceProvider = new RSACryptoServiceProvider();
            rsaCryptoServiceProvider.FromXmlString(File.ReadAllText("All.xml"));
            byte[] data= rsaCryptoServiceProvider.Encrypt(Encoding.ASCII.GetBytes(textBox1.Text), true);
            textBox1.Text = Convert.ToBase64String(data);
        }
    }
}